<?php

class Form_Admin_Activity extends QForm
{
    /**
     * 创建 Form_Admin_Activity 表单对象
     *
     * @param string $action
     * @param string $status
     *
     * @return Form_Admin_Activity
     */
    static function createForm($action, $status = 'create')
    {
        return self::_createFromConfig($action, 'activity_form.yaml');
    }

    /**
     * 从配置文件创建表单
     *
     * @param string $action
     * @param string $config_name
     *
     * @return Form_Admin_Activity
     */
    static protected function _createFromConfig($action, $config_name)
    {
        $form = new Form_Admin_Activity('Form_Admin_Activity', $action);
        $filename = rtrim(dirname(__FILE__), '/\\') . DS . $config_name;
        $form->loadFromConfig(Helper_YAML::loadCached($filename));
        $form->addValidations(Activity::meta());
        return $form;
    }
}

